// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import App from './App';
import router from './router';
import axios from 'axios';
import iconSvg from '@/components/iconSvg';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.config.productionTip = false;
import VueClipboard from 'vue-clipboard2';
import utils from '@/components/utils.js';

Vue.prototype.$utils = utils;
Vue.use(VueClipboard);
// 引入vue-amap
Vue.use(ElementUI);
// 测试版
Vue.prototype.codeHttp = 'http://api1.ittun.com/'
Vue.prototype.HTTP = 'http://api1.ittun.com/'
axios.defaults.baseURL = 'http://api.ittun.com'


// Vue.prototype.codeHttp = 'http://api.131452.com/'
// Vue.prototype.HTTP = 'http://api.131452.com/'

// axios.defaults.baseURL = 'http://api.131452.com/'
// Vue.prototype.codeHttp = 'http://193.112.234.181/'
// Vue.prototype.HTTP = 'http://193.112.234.181/'
// axios.defaults.baseURL = 'http://193.112.234.181/'



axios.defaults.timeout=8000;

Vue.prototype.axios = axios;

// fontIcon 若在阿里图标中添加了新图标,请在index.html中更新代码
Vue.component('icon-svg', iconSvg);




//拦截器
axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  config.headers = {
    // "ng-params-one": localStorage.getItem('account'),
    // "ng-params-two": localStorage.getItem('token')

    "ng-params-one": '13270068443',
    "ng-params-two": '343306a20694ef1f5408e858aa0d25bd178683d0'

  };

  return config;
}, function (error) {
  // Do something with request error
  return Promise.reject(error);
});

// 定义过滤器
Vue.filter('timestampToTime', function (value) {
  return utils.timestampToTime(value);
});
//金额过滤器
Vue.filter('NumFormat', function(value) {
  if(!value) return '0.00';
  value=value+"";
  var intPart = Number(value).toFixed(0); //获取整数部分
  var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断

  var floatPart = ".00"; //预定义小数部分
  var value2Array = value.split(".");

  //=2表示数据有小数位
  if(value2Array.length == 2) {
    floatPart = value2Array[1].toString(); //拿到小数部分

    if(floatPart.length == 1) { //补0,实际上用不着
      return intPartFormat + "." + floatPart + '0';
    } else {
      return intPartFormat + "." + floatPart;
    }

  } else {
    return intPartFormat + floatPart;
  }

});

new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: {
    App
  }
})
